#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: title09_1斗地主顺子.py 
@version:
@time: 2023/05/27 
"""
def main():
    line = input().strip()
    solution(line)


def solution(line):
    split_ = line.split(" ")
    index = [""] * 13
    convert(split_, index)

    res_set = []
    i = 1
    count = 0
    while i < len(index):

        builder = ""
        while i < len(index) and index[i] != "":
            builder += index[i] + " "

            count += 1
            i += 1

        if count >= 5:
            res_set.append(builder[:-1])
            break

    if len(res_set) == 0:
        print("No")
    else:
        for res in res_set:
            print(res)


def convert(split, ints):
    for str_ in split:
        if len(str_) == 1:
            c = str_[0]
            if c.isdigit():
                ints[int(c) - 2] = str_
            else:
                if c == "A":
                    ints[12] = str_
                elif c == "J":
                    ints[9] = str_
                elif c == "Q":
                    ints[10] = str_
                elif c == "K":
                    ints[11] = str_
        else:
            ints[8] = str_


if __name__ == '__main__':
    main()

